﻿using Quartz;

namespace SmartAgricultureService.Jobs
{
    public class CreateJob : IJob
    {
        private static bool _running;
        private readonly JobRunner _runner;
        public CreateJob(IServiceProvider provider)
        {
            using var scope = provider.CreateScope();
            _runner = scope.ServiceProvider.GetService<JobRunner>();
        }
        public async Task Execute(IJobExecutionContext context)
        {
            if (!_running)
            {
                _running = true;
                await _runner.CreateReport();
                _running = false;
            }
        }
    }
}